<template>
    <div id="app">
        <keep-alive>
            <router-view v-if="$route.meta.keepAlive"/>
        </keep-alive>
        <router-view v-if="!$route.meta.keepAlive"></router-view>
    </div>
</template>
<script>
    import {
        mapState,
        mapMutations
    } from 'vuex'

    export default {
        name: 'App',
        computed: {
            ...mapState(['likes'])
        },
        provide() {
            return {
                reload: this.reload
            }
        },
        data() {
            return {
                isRouterAlive: true
            }
        },
        mounted() {
            this.$http.get("/collect/getUserBeLiked").then((res) => {
                this.sendToLikes(res.data.data)
            })
        },
        methods: {
            ...mapMutations(['sendToLikes']),
            reload() {
                this.isRouterAlive = false
                this.$nextTick(function () {
                    this.isRouterAlive = true
                })
            }
        }
    }
</script>
<style lang="less">

    body {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        background-color: #f4f4f4;
    }

    p {
        margin: 0;
    }
</style>
